var uname=document.querySelector(".logbk1 .logbk .login #username");
var pwd=document.querySelector('#pwd');
let fm=document.getElementById("dl");
let mn=document.getElementById("unamemsg");
let mp=document.getElementById("pwdmsg");
let mf=false;
let pf=false;


    

$("#smdl").click(function(){
    $(this).css({
        "color": "#f60",
    });
    $(".smdl").css("display", "block");
    $("#zhdl").css({
        "color": "#333", 
    });
    $(".zhdl").css("display", "none");
})
$("#zhdl").click(function(){
    $(this).css({
        "color": "#f60",
    });
    $("#smdl").css({
        "color": "#333",
    });
    $(".zhdl").css("display", "block");
    $(".smdl").css("display", "none");
})
    
    
    uname.addEventListener("blur",function(){
        let reg =/^[a-zA-Z0-9_]{6,12}$/ ;//用户名验证
        //reg.test( this.value);
        console.log(reg.test( this.value));
        if(reg.test( this.value)){
            mn.style.color="green";
            mn.innerHTML="验证通过";
            this.style.borderColor="green";
             mf=true;
        }else{
            mn.style.color="red";
            mn.innerHTML="验证失败";
            this.style.borderColor="red";
             mf=false;
        }
    })
    pwd.addEventListener("blur",function(){
        let reg =/^[a-zA-Z0-9_]{6,12}$/ ;//密码验证
        //reg.test( this.value);
        //console.log(reg.test( this.value));
        if(reg.test( this.value)){
            mp.style.color="green";
            mp.innerHTML="验证通过";
            this.style.borderColor="green";
             pf=true;
        }else{
            mp.style.color="red";
            mp.innerHTML="验证失败";
            this.style.borderColor="red";
             pf=false;
        }
    })
    
    
    
   
//表单提交之前的验证
fm.addEventListener("submit",function(e){
    if(!mf){
        mn.style.color="red";
        mn.innerHTML="验证失败";
        uname.style.borderColor="red";
        e.preventDefault();
    }
    if(!pf){
        mp.style.color="red";
        mp.innerHTML="验证失败";
        pwd.style.borderColor="red";
        e.preventDefault();
    }

})

    
    
    
        
    


    
        
            
        
    